package com.yyaccp.appinfo.service;

import com.yyaccp.appinfo.domain.DevUser;
import com.yyaccp.appinfo.exception.LoginExceptin;
import com.yyaccp.appinfo.mapper.DevUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 天天向上 （john.yi@qq.com）
 * @date 2020/11/20.
 */
@Service
public class DevUserService {
    @Autowired
    private DevUserMapper devUserMapper;

    public DevUser login(DevUser user) throws LoginExceptin {
        DevUser devUser = devUserMapper.selectByDevCode(user.getDevCode());
        if(devUser == null) {
            throw new LoginExceptin("用户不存在");
        }
        if(!devUser.getDevPassword().equals(user.getDevPassword())) {
            throw new LoginExceptin("密码不正确");
        }
        return devUser;
    }
}
